<?php
/**
 * Created by PhpStorm.
 * User: July
 * Date: 2019/3/15
 * Time: 18:18
 */

use yii\helpers\Html;
use yii\grid\GridView;
use yii\widgets\Pjax;

/* @var $this yii\web\View */
/* @var $dataProvider yii\data\ActiveDataProvider */

$this->title = '卡券列表';
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="materials-index">

    <h1><?= Html::encode($this->title) ?></h1>
    <?php Pjax::begin(); ?>

    <p>
        <?= Html::a('创建卡券', ['create'], ['class' => 'btn btn-success']) ?>
    </p>

    <?= GridView::widget([
        'dataProvider' => $dataProvider,
        'columns' => [
            'id',
            'card_name',
            'card_id',
            [
                'class' => 'yii\grid\ActionColumn',
                'header' => '操作',
                'template' => ' {view} {update} {delete} {msg} {code}',
                'buttons' => [
                    'view' => function ($url, $model, $key) {
                        $options = [
                            'title' => Yii::t('yii', 'View'),
                            'aria-label' => Yii::t('yii', 'View'),
                            'data-pjax' => '0',
                        ];
                        return Html::a('<span class="glyphicon glyphicon-eye-open"></span>', $url, $options);
                    },
                    'update' => function ($url, $model, $key) {
                        $options = [
                            'title' => Yii::t('yii', 'Update'),
                            'aria-label' => Yii::t('yii', 'Update'),
                            'data-pjax' => '0',
                        ];
                        return Html::a('<span class="glyphicon glyphicon-pencil"></span>', $url, $options);
                    },
                    'delete' => function ($url, $model, $key) {
                        $options = [
                            'title' => Yii::t('yii', 'Delete'),
                            'aria-label' => Yii::t('yii', 'Delete'),
                            'data-confirm' => Yii::t('yii', 'Are you sure you want to delete this item?'),
                            'data-method' => 'post',
                            'data-pjax' => '0',
                        ];
                        return Html::a('<span class="glyphicon glyphicon-trash"></span>', $url, $options);
                    },
                    'msg' => function ($url, $model, $key) {
                        $options = [
                            'title' => Yii::t('yii', '给用户发送卡券消息'),
                            'aria-label' => Yii::t('yii', 'Msg'),
                            'data-pjax' => '0',
                        ];
                        return Html::a('<span class="glyphicon glyphicon-briefcase"></span>', $url, $options);
                    },
                    'code' => function ($url, $model, $key) {
                        $options = [
                            'title' => Yii::t('yii', '创建二维码投放卡券'),
                            'aria-label' => Yii::t('yii', 'Code'),
                            'data-pjax' => '0',
                        ];
                        return Html::a('<span class="glyphicon glyphicon-barcode"></span>', $url, $options);
                    },
                ]

            ],
        ],
    ]); ?>
    <?php Pjax::end(); ?>
</div>